import { defineStore } from "pinia";

export const useCouponsStore = defineStore('coupons', {
  state: () => {
    return {
      coupons: [],
      list: [{
        id: 1000,
        condition: '艾尔登法环\n满150减10元',
        reason: '只能用于目标游戏',
        value: 1000,
        name: '艾尔登法环',
        startAt: 1489104000,
        endAt: 1514592000,
        valueDesc: '10',
        unitDesc: '元',
      }, {
        id: 1003,
        condition: '严阵以待\n满100减10元',
        reason: '只能用于目标游戏',
        value: 1000,
        name: '严阵以待',
        startAt: 1489104000,
        endAt: 1514592000,
        valueDesc: '10',
        unitDesc: '元',
      }, {
        id: 1007,
        condition: '双子星：盛气凌人\n满50减5元',
        reason: '只能用于目标游戏',
        value: 500,
        name: '双子星：盛气凌人',
        startAt: 1489104000,
        endAt: 1514592000,
        valueDesc: '5',
        unitDesc: '元',
      },]
    }
  },
  actions: {
    getCoupons(userId) {
      new Promise((resolve, reject) => {
        resolve(this.list)
      }).then(res => {
        this.coupons.push(...this.list)
      })
    }
  },
  getters: {

  }
})